import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/net/response/service_order_ddetail_data.dart';
import 'package:ls_work/viewmodel/service_order/service_order_detail_info_view_model.dart';

class ServiceOrderDetailInfoWidget extends BaseStatefulMvvmWidget{
  final String orderId;
  final Function(ServiceOrderDdetailData detail) onLoadSuccess;
  ServiceOrderDetailInfoWidget(this.orderId,this.onLoadSuccess);

  @override
  State<StatefulWidget> createState() => ServiceOrderDetailInfoState();

}

class ServiceOrderDetailInfoState extends BaseMvvmState<ServiceOrderDetailInfoViewModel,ServiceOrderDetailInfoWidget>{
  @override
  Widget buildLoadingContentView() {
    return viewModel.detailInfoWidget();
  }

  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  ServiceOrderDetailInfoViewModel createViewModel() {
    return ServiceOrderDetailInfoViewModel(context,widget.orderId,(detail){
      widget.onLoadSuccess(detail);
    });
  }

  @override
  void onRetryClick() {
    viewModel.requestRefresh(showAni: false);
  }

}